﻿// =================================================================== 
// Module说明
//====================================================================
// 创建时间：2018-05-17 14:16:39
// 负责人：Sushee
// ===================================================================
using System;
using System.Data;
using System.Collections.Generic;
using OF.Utility;
using OF.Component.Model;
using OF.Component.IDAL;
using OF.Component.Factory;
namespace OF.Component.BLL
{
	
	/// <summary>
	///行为日志
	/// </summary>
	public partial class LogActionOperate
	{
    
        private static readonly string CACHE_KEY = "OF.BLL.LogActionInfo";
        private static readonly ILogAction dal=  LogAction.CreateInstance();
        
        
        
         public static int GetMaxID()
         {
            return dal.GetMaxID();
         }
        
		public static long Insert(LogActionInfo info)
		{
			long reValue=dal.Insert(info);
            CacheUtility.RemoveCache(CACHE_KEY,new string[]{info.ActionLogID.ToString()});
            return reValue;
		}
        
		public static void Update(LogActionInfo info)
		{
			dal.Update(info);
            CacheUtility.RemoveCache(CACHE_KEY,new string[]{info.ActionLogID.ToString()});
		}
        
        public static void Delete(long actionLogID)
		{
           
            dal.Delete(actionLogID);
            
            CacheUtility.RemoveCache(CACHE_KEY,new string[]{actionLogID.ToString()});			
		}
      
		public static IList<LogActionInfo> Search(out int pageCount, int pageIndex, int pageSize, string where, string orderField, bool isDesc)
		{
			object[] objList = (object[])CacheUtility.GetCache(CACHE_KEY, new string[] { pageIndex.ToString(), pageSize.ToString(), where, orderField.ToString(), isDesc.ToString() });
            if (objList == null)
            {
                objList = new object[2];
                objList[0] = dal.Search(out pageCount, pageIndex, pageSize, where, orderField, isDesc);
                objList[1] = pageCount;
                CacheUtility.AddCache(objList, CACHE_KEY, new string[] { pageIndex.ToString(), pageSize.ToString(), where, orderField.ToString(), isDesc.ToString() });
            }
            pageCount = Convert.ToInt32(objList[1]);
            return (IList<Model.LogActionInfo>)objList[0];
		}
        
          public static LogActionInfo GetByID(long actionLogID)
		{
            LogActionInfo info = (LogActionInfo)CacheUtility.GetCache(CACHE_KEY,new string[]{actionLogID.ToString()});
            if(info==null)
            {
                info = dal.GetByID(actionLogID);
                CacheUtility.AddCache(info,CACHE_KEY,new string[]{actionLogID.ToString()});
            }
            return info;
			
		}
	}
	
}